home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / int_23.arc / INT23.DOC < prev    next >
Encoding:
Text File  |  1988-03-15  |  2.8 KB  |  65 lines

  1. This ARC contains a couple of files that illustrate how to handle the type of
  2. ^C handling discussed in a recent thread on the MSOFT Forum of CompuServe.
  3.  
  4. Hitting Ctrl-Break has the same effect as ^C, as can be seen by running the
  5. test program.
  6.  
  7. A sample replacement function for getch is provided illustrating how to get
  8. characters and post the INT 23 (control-C exception).  Users can feel free
  9. to modify it to serve their own purposes.
  10.  
  11. According to Advanced MS-DOS, you cannot post INT 23 yourself.  You certainly
  12. cannot post it with the C runtime routines (see messages below), but you can
  13. apparently post it properly with the MASM routine included in this ARC file.
  14.  
  15. However, for some reason that I decided not to trace, you MUST restore the
  16. signal after taking it, as illustrated in the demonstration program.  It is
  17. not properly reset to the standard processing, SIG_DFL, but seems to be reset
  18. to SIG_IGN.
  19.  
  20. Much thanks for Richard Shupak for pushing me to rewrite the MASM code a few
  21. times before public release; the last time to allow CV walkbacks.
  22.  
  23. Questions and comments can be made to the author via the MSOFT forum on
  24. CompuServe.  Address messages to: Noel J. Bergman 73220,1030.
  25.  
  26. The original question and the response documenting this ARC is as follows:
  27.  
  28. --------------
  29.  
  30. S3/C & MASM 25-Jul-87  23:29:54
  31. Sb: Ctrl-C & Ctrl-Break
  32.  
  33. I have a question about C's handling of the Ctrl-C and Ctrl-Break. How can I
  34. prevent the ^C from being displayed. I am using the signal fuction pointing to
  35. an empty fucntion to prevent my program from being aborted during these
  36. keystrokes. I have not found a way to supress the ^C from being printed. I
  37. also tried trapping the BIOS Ctrl-Brake interrupt, but it doesn't work for
  38. Ctrl-C.
  39.                      Thanks
  40.  
  41.  
  42.  
  43. S3/C & MASM 26-Jul-87  13:37:22
  44. Sb: #70922-Ctrl-C & Ctrl-Break
  45.  
  46. The only way I know of to do that is to use a function such as #7, which
  47. doesn't perform ^C processing, and to issue the INT 23 yourself.  If you use
  48. DOS #8, you get the ^C echo.
  49.  
  50. Unfortunately, you can't just issue an int86(0x23, ..., ...) call from C,
  51. despite the example on page 242 of the C runtime reference.  It just won't
  52. work.  However, I do have a MASM routine that seems to make it work out ok.
  53.  
  54. For some reason that I am not going to trace, if you use my example the signal
  55. is not automatically reset to SIG_DFL after each processing; it ends up that
  56. there is no processing of the signal at all.  So you MUST reset the signal
  57. within your handler and you are completely responsible for determining when
  58. you want the program to terminate.
  59.  
  60. I will upload an ARC with the MASM code and a little test program later today.
  61. If and when the Sysops decide to make it public, there should be a public
  62. message saying it is available.
  63.  
  64. --------------
  65.